package com.wg.dome.repository;

import com.wg.dome.entity.user.ItemEntity;
import com.wg.core.lang.HashTable;
import com.wg.db.cache.AbstractCollectionRepository;

import java.io.Serializable;
import java.util.HashMap;

public class ItemRepository extends AbstractCollectionRepository<ItemEntity> {
    public ItemRepository() {
        super(ItemEntity.class);
    }

    /**
     * 数据转换为hashtable
     */
    public HashTable[] toHashTables(long playerId) {
        HashMap<Serializable, ItemEntity> entityHashMap = getAll(playerId, null);
        HashTable[] hashTables = new HashTable[entityHashMap.size()];
        int i = 0;
        for (ItemEntity itemEntity : entityHashMap.values()) {
            hashTables[i++] = itemEntity.toHashTable();

        }
        return hashTables;
    }

    public ItemEntity getItem(long playerId , int itemId){
        ItemEntity entity = get(playerId, itemId);
        return entity;
    }
}
